<?php if (!defined('SERVER_ROOT')) exit('No direct script access allowed');

class nhomquyen_Controller extends Controller {

    function __construct(){
        parent::__construct('phanquyen', 'nhomquyen');
        $this->check_login();
        $this->view->template->menu_html =$this->CREATE_MENU();
        $this->view->template->nhacviec_html =$this->CREATE_NHAC_VIEC();
        $this->CHECK_QUYEN('phanquyen', 'nhomquyen');
    }

    function main(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->dsp_all_nhomquyen();
    }

    function dsp_all_nhomquyen(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $VIEW_DATA['arr_all_nhomquyen']= $this->model->qry_all_nhomquyen();
        $this->view->render('dsp_all_nhomquyen', $VIEW_DATA);
    }
    public function dsp_single_nhomquyen($MA_NHOM_QUYEN){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $MA_NHOM_QUYEN = replace_bad_char($MA_NHOM_QUYEN);
        $VIEW_DATA['arr_single_nhomquyen'] = $this->model->qry_single_nhomquyen($MA_NHOM_QUYEN);
        $this->view->render('dsp_single_nhomquyen', $VIEW_DATA);
    }
    public function update_nhomquyen(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_nhomquyen';
        $this->model->update_nhomquyen();
    }
    public function delete_nhomquyen(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_nhomquyen';
        $this->model->delete_nhomquyen();
    }
    /****************************form dsp_all_nhomquyen***********************/
    public function dsp_all_quyen($MA_NHOM_QUYEN){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $MA_NHOM_QUYEN  = replace_bad_char($MA_NHOM_QUYEN);
        $TEN_NHOM_QUYEN = replace_bad_char($_REQUEST['hdn_item_name']);
        $VIEW_DATA['var_manhomquyen'] = $MA_NHOM_QUYEN;
        $VIEW_DATA['var_tennhomquyen'] = $TEN_NHOM_QUYEN;
        $VIEW_DATA['arr_all_quyen'] = $this->model->SELECT_ALL_TR_QUYEN_CUA_NQ($MA_NHOM_QUYEN);
        $this->view->render('dsp_all_quyen', $VIEW_DATA);
    }
    public function update_quyencuanhomquyen()
    {
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_nhomquyen';
        $this->model->update_nhomquyencanbo();
    }
}